package com.google.gwt.gfx.client.graphics.vml;

import com.google.gwt.gfx.client.graphics.Graphic;
import com.google.gwt.gfx.client.shared.Size;
import com.google.gwt.gfx.client.style.GFXStyle;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;

public class VMLCoordSizeStyle extends GFXStyle {

	public VMLCoordSizeStyle(Graphic g) {
		super(g);
	}

	public VMLCoordSizeStyle(Graphic g, Element element) {
		super(g, element);
	}

	public Size getValue() {
		String[] words = DOM.getElementProperty(element(), "coordsize").split(
				",");
		if (words.length != 2) {
			return null;
		}
		Size size = new Size();
		size.setWidth(Integer.parseInt(words[0]));
		size.setHeight(Integer.parseInt(words[1]));
		return size;
	}

	public void update(int width, int height) {
		DOM.setElementProperty(element(), "coordsize", width + "," + height);
	}

}
